/**
 * Copyright (c) 2012 Axa Holding Belgium, SA. All rights reserved.
 * This software is the confidential and proprietary information of the AXA Group.
 */
package chabernac.android.wordbattle.model;


public class WordSnakeSelectionHelper extends AllDirectionsSelectionHelper {

  @Override
  public boolean isSelectionAllowed( WordRaster aRaster, Letter aNewLetterToSelect ) {
    Word theLastFoundWord = aRaster.getLastFoundWord();
    
    //the first letter of the new word must start with the last letter of the previously found word
    
    if(theLastFoundWord != null && 
        aRaster.getSelectedLetters().isEmpty() && 
        aNewLetterToSelect != theLastFoundWord.getLastLetter()){
      return false;
    }
    
    return super.isSelectionAllowed( aRaster, aNewLetterToSelect );
    
  }
}
